<%@ taglib prefix="c" uri="http://www.codecoord.com" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://www.codecoord.com/fmt" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <style>#navbar-default {background-color: #71BD71;}
    .layui-input-block{
        margin-left: 0;
    }
    </style>
</head>
<body>
<div class="layui-container">
<form id="answerform" class="layui-form" action="">
    <div style="height: 30px;" class="layui-row layui-text">1.您对本次视频会议的体验度如何？</div>
    <div style="height: 50px;" class="layui-row layui-form-item" pane="">
        <div class="layui-col-xs3 " >
            <input  type="radio" name="satisfeid" value="一般" lay-skin="primary" title="一般" checked="">
        </div>
        <div class="layui-col-xs3 ">
        <input  type="radio" name="satisfeid" value="满意" lay-skin="primary" title="满意">
        </div>
        <div class="layui-col-xs5 ">
        <input  type="radio" name="satisfeid" value="非常满意" lay-skin="primary" title="非常满意" >
        </div>
    </div>
    <div style="height: 40px;" class="layui-row layui-text">2.本次视频会议是否解决了您的问题，满意度如何？</div>
    <div style="height: 50px;" class="layui-row layui-form-item" pane="">
        <div class="layui-col-xs4" >
            <input  type="radio" name="question" value="解决40%" lay-skin="primary" title="解决40%" checked="">
        </div>
        <div class="layui-col-xs4 ">
            <input  type="radio" name="question" value="解决70%" lay-skin="primary" title="解决70%">
        </div>
        <div class="layui-col-xs4 ">
            <input  type="radio" name="question" value="解决90%" lay-skin="primary" title="解决90%" >
        </div>
    </div>
    <div style="height: 30px;" class="layui-row layui-text">3.您希望的视频诊疗指导频率或时间？</div>
    <div style="height: 30px;" class="layui-row layui-form-item" pane="">
        <div class="layui-col-xs6" >
            <input  type="checkbox" value="周/次" name="rate[1]" lay-skin="primary" title="周/次" checked="">
        </div>
        <div class="layui-col-xs6">
            <input  type="checkbox" value="每天" name="rate[2]" lay-skin="primary" title="每天">
        </div>
    </div>
    <div style="height: 50px;" class="layui-row layui-form-item" pane="">
        <div class="layui-col-xs6 " >
            <input  type="checkbox" value="固定时间" name="rate[3]" lay-skin="primary" title="固定时间" checked="">
        </div>
        <div class="layui-col-xs6 ">
            <input  type="checkbox" value="随时在线" name="rate[4]" lay-skin="primary" title="随时在线">
        </div>
    </div>
    <div style="height: 40px;" class="layui-row layui-text">4.视频远程诊疗，您是否愿意患者或患者家属共同参与？</div>
    <div style="height: 50px;" class="layui-row layui-form-item" pane="">
        <div class="layui-col-xs6" >
            <input  type="radio" name="isnot" value="是" lay-skin="primary" title="是" checked="">
        </div>
        <div class="layui-col-xs6 ">
            <input  type="radio" name="isnot" value="否" lay-skin="primary" title="否">
        </div>
    </div>
    <div style="height: 30px;" class="layui-row layui-text">5.您倾向于什么样专家解决问题？</div>
    <div style="height: 30px;" class="layui-row layui-form-item" pane="">
        <div class="layui-col-xs6" >
            <input  type="checkbox" name="expert[1]" value="熟悉的医生" lay-skin="primary" title="熟悉的医生" checked="">
        </div>
        <div class="layui-col-xs6 ">
            <input  type="checkbox" name="expert[2]" value="名气大的医生" lay-skin="primary" title="名气大的医生">
        </div>

    </div>
    <div style="height: 50px;" class="layui-row layui-form-item" pane="">
    <div class="layui-col-xs12">
        <input  type="checkbox" name="expert[3]" value="二级及二级以上的医生" lay-skin="primary" title="二级及二级以上的医生" >
    </div>
    </div>
    <div style="height: 40px;" class="layui-row layui-text">6.本相对于患者亲自去省城诊疗，远程视频会诊一位患者的价值评估？</div>
    <div style="height: 50px;" class="layui-row layui-form-item" pane="">
        <div class="layui-col-xs4" >
            <input  type="radio" name="RMB" value="100元" lay-skin="primary" title="100元" checked="">
        </div>
        <div class="layui-col-xs4 ">
            <input  type="radio" name="RMB" value="200元" lay-skin="primary" title="200元">
        </div>
        <div class="layui-col-xs4 ">
            <input  type="radio" name="RMB" value="300元" lay-skin="primary" title="300元" >
        </div>
    </div>
    <div style="height: 40px;" class="layui-row layui-text">7.在这次远程诊疗服务中，您认为哪位专家的建议帮助最大？</div>
    <div class="layui-row layui-form-item layui-form-text">
        <div>
            <textarea name="advise1" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div style="height: 40px;" class="layui-row layui-text">8.对我们下次举办视频远程诊疗，您的指导建议是？</div>
    <div class="layui-row layui-form-item layui-form-text">
        <div>
            <textarea name="advise2" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <input hidden  name="appointmentId" value="${appointmentId}">
    <input hidden id="userId" name="userId" value="${userId}">
    <input hidden id="datetime" name="datetime" value="">
    <input hidden id="doctor" name="doctor" value="">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</div>
</body>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
        ,layer = layui.layer
        ,layedit = layui.layedit
        ,laydate = layui.laydate;

        //日期
        laydate.render({
        elem: '#date'
    });
        laydate.render({
        elem: '#date1'
    });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
        title: function(value){
        if(value.length < 5){
        return '标题至少得5个字符啊';
    }
    }
        ,pass: [
        /^[\S]{6,12}$/
        ,'密码必须6到12位，且不能出现空格'
        ]
        ,content: function(value){
        layedit.sync(editIndex);
    }
    });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
        layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
        offset: '6px'
    });
        layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
    });

        //监听提交
        form.on('submit(demo1)', function(data){
            var i=0;
            var j=0;
            var s=0;
            var dateTime="";
            var doctordata="";
           var t= JSON.stringify(data.field);
           var obj=eval('(' + t + ')');
           //判断是否有未填写的问题
            for(var str in obj){
                if((str.substring(0, 4) == "rate")||(str.substring(0, 6) == "expert")){
                   j++;
                    //对多选题做字段拼接处理
                   if(str.substring(0, 4) == "rate"){doctordata+=obj[str]+",";}
                   else{dateTime+=obj[str]+",";}
                }else if((str.substring(0, 6) == "advise")){
                    if (obj[str]!=""){s++;}
                }else{i++;}

            }
            //对多选题做尾部逗号处理
            dateTime=dateTime.substring(0,dateTime.lastIndexOf(','));
            doctordata=doctordata.substring(0,doctordata.lastIndexOf(','));
            $("#datetime").val(dateTime);
            $("#doctor").val(doctordata);
            if(i<8||j<2||s<2){layer.msg('您有未填写的问题！', {icon: 7,time:3000});
            return false;} else {

                $.ajax({ url: "${pageContext.request.contextPath}/answer/save",
                    type: "get",
                    data:$("#answerform").serialize(),
                    success: function(data){
                        layer.msg('提交成功！', {icon: 6,time:3000});
                    }});
            }


        return false;
    });

        //表单赋值
        layui.$('#LAY-component-form-setval').on('click', function(){
        form.val('example', {
        "username": "贤心" // "name": "value"
        ,"password": "123456"
        ,"interest": 1
        ,"like[write]": true //复选框选中状态
        ,"close": true //开关状态
        ,"sex": "女"
        ,"desc": "我爱 layui"
    });
    });
        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function(){
        var data = form.val('example');
        alert(JSON.stringify(data));
    });
    });
</script>
</html>
